package com.pagepub.farm.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.simple.ParameterizedRowMapper;


import com.pagepub.farm.pojo.Player;

public class PlayerDao extends BaseDao<Player> {
	
	public PlayerDao(){
	
	}

	@Override
	public void initSql() {
		TABLE_NAME="player_gameinfo";
		
		INSERT_SQL = "INSERT  INTO "+TABLE_NAME+" (" +
				"playerId,loginName)VALUES(" +
				":playerId,:loginName)";

		DELETE_SQL = "DELETE FROM "+ TABLE_NAME +" WHERE playerid=?";

		UPDATE_SQL = "UPDATE "+ TABLE_NAME+" SET " +
				"loginName=:loginName" +
				" WHERE playerid=:playerid";
	}

	@Override
	public void initMapper() {
		mapper = new ParameterizedRowMapper<Player>() {
			public Player mapRow(ResultSet rs, int rowNum) throws SQLException {
				Player user = new Player();
				user.setPlayerId(rs.getInt("PlayerId"));
				user.setLoginName(rs.getString("loginName"));
				return user;
			}
		};
		
	}

}
